/*
 * 作者: 黄伟
 * 时间: 2017-01-19 
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {

	require("jquery");
	var appInfo = require('app/AppInfo');
	var c = require('app/utils/CommonUtils');
	var tip = require('app/utils/TipUtils');
	
	var action = {};

	var win = window;

	action.renderItem = function(item){
		var item_div = 
		'<li class="aui-list-item select-item" id="'+item.val+'" data-val="'+item.text+'">'+
            '<div class="aui-list-item-label-icon">'+
                '<i class="aui-iconfont aui-icon-right select-item-icon" style="display:none;color:rgb(237,116,55);"></i>'+
            '</div>'+
            '<div class="aui-list-item-inner select-item-text">'+
                item.text+
            '</div>'+
		'</li>';
		$("#items").append(item_div);
	}
	
	//{val:"val",text:"text"}
	action.selectItem = function(item){
		
		$("#items").find('.select-item-icon').hide();
		$("#items").find('.on').removeClass("on");
		if(!c.isNull(item)){
			var $itm = $("#items").find("#"+item.val);
			$itm.addClass("on");
			$itm.find('.select-item-icon').show();		
		}

	}
	
	action.getSelectedItem = function(){
		var $itm = $("#items").find('.on');
		var val = $itm.attr("id");
		var text = $itm.data("val");
		return {
			val: val,
			text: text
		};
	}

	action.listenClickItem = function(){
		$("#items").find('.select-item').click(function(){
			var item = {
				val:$(this).attr("id"),
				text:$(this).data("val")
			}
			action.selectItem(item);
		});
	}
	return action;
});
